package com.jiayen.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jiayen.R;


/**
 * Created by jiangyue on 2016/3/24.
 */
public class TabItemView extends LinearLayout{
    private View  childView;
    private TextView  name;
    private ImageView  icon;
    private Context context;
    public TabItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context =context;
        childView = LayoutInflater.from(context).inflate(R.layout.tab_item_jp,null);
        name = (TextView)childView.findViewById(R.id.name);
        icon = (ImageView)childView.findViewById(R.id.icon);
        name.setTextColor(getResources().getColor(R.color.bottom_bar_gray));
        addView(childView);
    }

    public TabItemView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TabItemView(Context context) {
        this(context, null, 0);
    }

    /**
     * 设置图片
     * @param imageId
     */
    public void setIcon(int imageId){
        icon.setImageResource(imageId);
    }

    /**
     * 设置名称
     * @param nameStr
     */
    public void setname(String nameStr){
        name.setText(nameStr);
    }

    /**
     * 设置名称
     * @param resourceId
     */
    public void setnameResource(int  resourceId){
        name.setText(context.getResources().getText(resourceId));
    }

    /**
     * 设置字体颜色变化
     * @param colorId
     */
    public void  setNameColor(int colorId){
        name.setTextColor(colorId);
    }
}
